<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions"  prefix="fn"%> 
<%@taglib uri="/billing" prefix="b"%>
<%@page import="com.admin.service.ProvinceService"%>
<%
response.setHeader("Cache-Control","no-cache"); //HTTP 1.1

//or response.setHeader("Cache-Control","no-store");//HTTP 1.1

response.setHeader("Pragma","no-cache"); //HTTP 1.0

response.setDateHeader ("Expires", 0); //prevents caching at the proxy server
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>计费后台管理</title>
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/css/managercss.css">
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/css/wbox.css">
<script type="text/javascript" src="<%=request.getContextPath() %>/js/jquery-1.4.min.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/js/jquery.form.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/js/wbox.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/js/validate.js"></script>
<script type="text/javascript">
<!--
	$(function(){
		$(".list div").mousemove(function(){
			$(this).css("background","#E3EEFF");
		}).mouseout(function(){
			$(this).css("background","");
		});
		$("#provinceId").val('${provinceId}');
		$("#isp").val('${isp}');
		$("#vodCustomized").val('${vodCustomized}');
	});

	function del(spId){
		if(confirm("你确认删除该SP吗?")){
			$.ajax({
				url:"<%=request.getContextPath() %>/admin/sp/del/"+spId,
				type:"GET",
				success:function(flag){
					if(flag=='1'){
						alert("删除成功!");
						window.location.reload();
					}else{
						alert("删除失败!");
					}
				}
			});
		}
	}
	function addSp(){
		var wBox = $("#ajax").wBox({
			requestType: "iframe",
			iframeWH:{width:700,height:600},
			target:"<%=request.getContextPath() %>/admin/sp/toadd",
			title: "添加新的SP"
		});
		wBox.showBox();
	}

	function back(){
		location.href="<%=request.getContextPath() %>/admin/company";
	}
	
	function fenpei(spid){
		var wBox = $("#ajax").wBox({
			requestType: "iframe",
			iframeWH:{width:700,height:600},
			target:"<%=request.getContextPath() %>/admin/sp/tofenpei/"+spid,
			title: "分配SP通道"
		});
		wBox.showBox();
	}

	function show(spId){
		var wBox = $("#ajax").wBox({
			requestType: "iframe",
			iframeWH:{width:700,height:600},
			target:"<%=request.getContextPath() %>/admin/sp/"+spId,
			title: "查看SP"
		});
		wBox.showBox();
	}
//-->
</script>
</head>
<body>
<div class="information">
	<div class="title">
		SP列表
	</div>
	<div class="search">
		<form action="<%=request.getContextPath() %>/admin/sp/list" method="post">
		<c:set value="${companyList}" var="companyList"></c:set>
		合作商
		<select name="companyId" id="companyId" style="width: 120px;">
			<option value="-1">-----请选择-----</option>
			<c:forEach items="${companyList}" var="p">
				<option value="${p.companyId }">${p.companyName }</option>
			</c:forEach>
		</select>
		SP通道名:<input name="spname" type="text" value=""/>|业务线:
		<select name="bussiness">
						<option value="">请选择</option>
						<option value="SMS">SMS</option>
						<option value="MMS">MMS</option>
						<option value="IVR">IVR</option>
						<option value="视频基地">视频基地</option>
						<option value="百宝箱游戏">百宝箱游戏</option>
						<option value="G+游戏">G+游戏</option>
						<option value="动漫基地">动漫基地</option>
						<option value="阅读基地">阅读基地</option>
						<option value="MM基地">MM基地</option>
						<option value="MDO业务">MDO业务</option>
					</select>
					指令:<input name="spcommand" type="text" value=""/>
					端口:<input name="spcode" type="text" value=""/>
		<input type="submit" value="查询">
		</form>
	</div>
			
	
	
	<table align="center" width="100%">
		<tr class="list" align="center">
		<td style="width:20px;">spid</td>
		<td style="width:70px;">公司名称</td>
			<td style="width:70px;">SP通道名</td>
			<td style="width:60px;">运营商</td>
			<td style="width:70px;">业务名称</td>
			<td style="width:70px;">业务线</td>
			<td style="width:60px;">指令</td>
			<td style="width:100px;">端口</td>
			<td style="width:40px;">资费</td>
			<td style="width:40px;">日限</td>
			<td style="width:40px;">月限</td>
			<td style="width:70px;">合作状态</td>
			<td style="width:100px;">支持省份</td>
			<td style="width:100px;">屏蔽地市</td>
			<td style="width:80px;">二次确认</td>
			<td style="width:80px;">操作</td>
		</tr>

	
		<c:forEach items="${pageBean.result}" var="sp" varStatus="status">
		
			<tr class="${status.index%2==0?'noselect':'select' }" align="center">
				<td style="width:20px;">${sp.id }</td>
				<td style="width:70px;">${sp.companyname }</td>
					<td style="width:70px;">${sp.spname }</td>
					<td style="width:60px;">
						<c:choose>
							<c:when test="${sp.spisp==1 }">移动</c:when>
							<c:when test="${sp.spisp==2 }">联通</c:when>
						</c:choose>
					</td>
					<td style="width:70px;">${sp.spcodename }</td>
					<td style="width:70px;">${sp.bussiness }</td>
					<td style="width:60px;">
					<c:choose>
					    <c:when test="${fn:length(sp.spcommand) > 50}">
					     <c:out value="${fn:substring(sp.spcommand, 0, 50)}..." />
					    </c:when>
					    <c:otherwise>
					     <c:out value="${sp.spcommand}" />
					    </c:otherwise>
					   	</c:choose>
					</td>
					<td style="width:100px;">
					<c:choose>
					    <c:when test="${fn:length(sp.spcode) > 50}">
					     <c:out value="${fn:substring(sp.spcode, 0, 50)}..." />
					    </c:when>
					    <c:otherwise>
					     <c:out value="${sp.spcode}" />
					    </c:otherwise>
					   	</c:choose>
					</td>
					<td style="width:40px;">${sp.spfee/100 }元</td>
					
					<td style="width:40px;">${sp.spdaylimit }</td>
					<td style="width:40px;">${sp.spmonthlimit }</td>
					<td style="width:70px;">
					<c:if test="${sp.spstatus==3}">
						<font color="red">精确已分配</font>
					</c:if>
					<c:if test="${sp.spstatus==1}">
						精确可用
					</c:if>
					<c:if test="${sp.spstatus==2}">
						模糊可用
					</c:if>
					<c:if test="${sp.spstatus==0}">
						<font color="red">停止</font>
					</c:if>
					</td>
					<td style="width:100px;">${sp.province }</td>
					<td style="width:100px;">${sp.shieldcity }</td>
					<td style="width:80px;">${sp.spmemo }</td>
					<td style="width:80px;">
						<a href="#" onclick="show(${sp.id})">查看</a>
						<a href="#" onclick="del(${sp.id})">删除</a>
						
						<a href="#" onclick="fenpei(${sp.id})">分配</a>
						
						
					</td>
			</tr>
		
		</c:forEach>
	</table>
	
	<!-- 
	<div class="listTitle">
		<ul>
			<li style="width:70px;">公司名称</li>
			<li style="width:70px;">SP通道名</li>
			<li style="width:60px;">运营商</li>
			<li style="width:70px;">业务名称</li>
			<li style="width:70px;">业务线</li>
			<li style="width:60px;">指令</li>
			<li style="width:100px;">端口</li>
			<li style="width:40px;">资费</li>
			<li style="width:40px;">日限</li>
			<li style="width:40px;">月限</li>
			<li style="width:70px;">合作状态</li>
			<li style="width:100px;">支持省份</li>
			<li style="width:100px;">屏蔽地市</li>
			<li style="width:80px;">二次确认</li>
			<li style="width:80px;">操作</li>
		</ul>
	</div>
	<div class="list">
		<c:forEach items="${pageBean.result}" var="sp" varStatus="status">
			<div class="${status.index%2==0?'noselect':'select' }">
				<ul>
					<li style="width:70px;">${sp.companyname }</li>
					<li style="width:70px;">${sp.spname }</li>
					<li style="width:60px;">
						<c:choose>
							<c:when test="${sp.spisp==1 }">移动</c:when>
							<c:when test="${sp.spisp==2 }">联通</c:when>
						</c:choose>
					</li>
					<li style="width:70px;">${sp.spcodename }</li>
					<li style="width:70px;">${sp.bussiness }</li>
					<li style="width:60px;">${sp.spcommand }</li>
					<li style="width:100px;">${sp.spcode }</li>
					<li style="width:40px;">${sp.spfee/100 }元</li>
					
					<li style="width:40px;">${sp.spdaylimit }</li>
					<li style="width:40px;">${sp.spmonthlimit }</li>
					<li style="width:70px;">
					<c:if test="${sp.spstatus==3}">
						<font color="red">精确已分配</font>
					</c:if>
					<c:if test="${sp.spstatus==1}">
						精确可用
					</c:if>
					<c:if test="${sp.spstatus==2}">
						模糊可用
					</c:if>
					<c:if test="${sp.spstatus==0}">
						<font color="red">停止</font>
					</c:if>
					</li>
					<li style="width:100px;">${sp.province }</li>
					<li style="width:100px;">${sp.shieldcity }</li>
					<li style="width:80px;">${sp.spmemo }</li>
					<li style="width:80px;">
						<a href="#" onclick="show(${sp.id})">查看</a>
						<a href="#" onclick="del(${sp.id})">删除</a>
						<c:if test="${sp.spstatus==1 or sp.spstatus==2}">
						<a href="#" onclick="fenpei(${sp.id})">分配</a>
						</c:if>
						
					</li>
					
				</ul>
				<div class="clear"></div>
			</div>
		</c:forEach>
	</div>
	 -->
	<jsp:include page="../page.jsp" flush="true"></jsp:include>
	<div class="search">
		<input type="button" name="bd" value="返回" onclick="back()"/>&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" name="bd" value="新增SP" onclick="addSp()"/>
	</div>
</div>
</body>
</html>